function UserInformationBox(){
	this.dom = this.createElement();

	this.user = null;
	this.width = 380;

	document.body.appendChild(this.dom.element);

	global.createObject('UserInformationBox', this);
}

UserInformationBox.prototype.createElement = function(){
	var el = document.createElement('DIV');
	el.id = 'userInformationBox';
	el.className = 'userInformationBox invisible';

	var picture = document.createElement('IMG');
	picture.className = 'picture';

	var name = document.createElement('P');
	name.className = 'name';

	var messageCounter = document.createElement('P');
	messageCounter.className = 'messageCounter';

	var idleTime = document.createElement('P');
	idleTime.className = 'idleTime';
	idleTime.innerHTML = '';

	var seeProfile = document.createElement('A');
	seeProfile.className = 'seeProfile';
	seeProfile.innerHTML = 'Ver perfil';
	seeProfile.target = 'blank';

	var arrow = document.createElement('DIV');
	arrow.className = 'arrow';

	el.appendChild(picture);
	el.appendChild(name);	
	el.appendChild(messageCounter);
	el.appendChild(idleTime);
	el.appendChild(seeProfile);
	el.appendChild(arrow);

	setEvent(el,'mouseout',hideInformationBox);

	return {element: el, messageCounter: messageCounter, idleTime: idleTime, picture: picture, name: name, seeProfile: seeProfile};
}

UserInformationBox.prototype.getIdleTime = function(){
	var d = new Date();
	var timeNow = d.getTime();

	var lastActivityTime = this.user.lastActivity.date.getTime();

	var secondsPast = (timeNow - lastActivityTime)/1000;
	
	var hours = Math.floor(secondsPast/3600);
	var minutesBase = secondsPast%3600;
	var minutes = Math.floor(minutesBase / 60);

	var string = '';

	if(secondsPast < 60){
		string = 'menos de 1 minuto';
	}else{
		var stringArray = new Array();
		
		if(hours > 0){
			if(hours == 1) stringArray.push('1 hora');
			else stringArray.push(hours+' horas');
		}

		if(minutes > 0){
			if(minutes == 1) stringArray.push('1 minuto');
			else stringArray.push(minutes+' minutos');
		}

		string = stringArray.join(' e ');
	}
	
	return string;
}

UserInformationBox.prototype.show = function(key){
	this.user = global.getObject('user', key);
	var position = getPosition(this.user.dom.element);
	
	var userMessageCounter = this.user.messageCounter;

	if(userMessageCounter == 0) userMessageCounterString = 'Não enviou mensagens';
	else if(userMessageCounter == 1) userMessageCounterString = 'Enviou 1 mensagem';
	else userMessageCounterString = 'Enviou '+userMessageCounter+' mensagens';

	this.dom.picture.src = this.user.getPicturePath('large');
	this.dom.name.innerHTML = this.user.name;
	
	var idleTimeContent = '';
	if(userMessageCounter > 0) idleTimeContent = 'Última enviada há '+this.getIdleTime();
	this.dom.idleTime.innerHTML = idleTimeContent;
	
	this.dom.messageCounter.innerHTML = userMessageCounterString;
	this.dom.seeProfile.href = 'https://www.facebook.com/'+this.user.id;

	//this.user.dom.element.appendChild(this.dom.element);
	//alert(position.left)
	this.dom.element.style.top = position.top+'px';
	this.dom.element.style.left = (position.left - this.width)+'px';
	//this.dom.element.style.position = 'relative';
	
	removeClass(this.dom.element,'invisible');
}

UserInformationBox.prototype.hide = function(){
	addClass(this.dom.element,'invisible');
}